<?php

namespace App\Admin\Controllers;

use App\model\panyuan\Gonggao;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;

class GonggaoController extends AdminController
{
    /**
     * Title for current resource.
     *
     * @var string
     */
    protected $title = '公告';

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        $grid = new Grid(new Gonggao);
        $grid->column('title','标题');
        $grid->column('created_at','创建时间');
        $grid->column('logo','缩略图')->display(function ($value){
            return \Storage::url($value);
        });
        return $grid;
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     * @return Show
     */
    protected function detail($id)
    {
        $show = new Show(Gonggao::findOrFail($id));



        return $show;
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        $form = new Form(new Gonggao);
        $form->text('title','标题')->required();
        $form->ckeditor('desc','内容')->required();
        $form->image('logo','缩略图')->required();
        return $form;
    }
}
